<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.forecast.forecastEntry.SearchField,
                 java.util.ArrayList,
                 com.scalar.forecast.forecastEntry.RowData,
                 com.scalar.forecast.commons.Constants,
                 java.util.Enumeration,
                 com.scalar.forecast.commons.SessionKeys,
                 com.scalar.forecast.forecastEntry.forms.ForecastEntryForm,
                 com.scalar.forecast.systemprefs.SystemPreferencesSingleton,
                 com.scalar.forecast.systemprefs.SystemPreferences"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld"  prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld"  prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-nested.tld"  prefix="nested"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld"  prefix="bean"%>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</SCRIPT>
<SCRIPT language=JavaScript src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</SCRIPT>
<SCRIPT>
           var prevPrice = 0; //this variable is used in the validations.js to validate the price.
           var noOfSlots = 0;
           var noOfRows = 0;
           var stack = new Array();
           var stackPtr = 0;
           function push ( obj )
           {
               stack [ stackPtr++ ] = obj;
           }
           function pop()
           {
               if ( stackPtr == 0 )
               {
                   return null;
               }
               return stack[ --stackPtr ];
           }
           function toggle ( level, img )
           {
               pushChilds ( level );
               childNode = pop();
               pa = document.getElementById ( "errorsId" );
               pa.innerHTML = "";
               if ( childNode == null )
               {
                   pa.innerHTML = "<li>No SubOrdinates Present</li>"
                   return;
               }
               var displayStatus = '';
               if ( childNode.style.display == 'block' )
               {
                   displayStatus = 'none';
                   childNode.style.display = displayStatus;
                   if ( img != null )
                       img.src ="<%=chipTracContext%>/jsp/includes/images/plus.gif";
                   pushChilds ( childNode );
               }
               else
               {
                   displayStatus = 'block'
                   if ( img != null )
                       img.src ="<%=chipTracContext%>/jsp/includes/images/minus.gif";
                   childNode.style.display = displayStatus;
               }
               imgElmt = document.getElementById( childNode.id + 'img' );
               if ( imgElmt != null )
               {
                   if ( displayStatus == 'block' )
                       imgElmt.src = "<%=chipTracContext%>/jsp/includes/images/plus.gif";
               }
               while ( true )
               {
                   childNode = pop();
                   if ( childNode == null )
                   {
                       return;
                   }
                   childNode.style.display = displayStatus;
                   imgElmt = document.getElementById( childNode.id + 'img' );
                   if ( imgElmt != null )
                   {
                       if ( displayStatus == 'block' )
                           imgElmt.src = "<%=chipTracContext%>/jsp/includes/images/plus.gif";
                   }
                   if ( displayStatus == 'none' ) //sub childNodes also needs to be hidden.
                       pushChilds ( childNode )
              }
           }
           function pushChilds ( level )
           {
               var i = 1;
               while ( true )
               {
                   childNode1 = document.getElementById ( level.id + "c" + i );
                   if ( childNode1 != null )
                   {
                       push ( childNode1 );
                   }
                   else
                   {
                       break;
                   }
                   i++;
               }
          }
       function toggleEnableDisable( chkbox, lineNo ) //lineNo --> starts from zero
       {
            var form = document.forecastEntryBuildForm;

            var isDisabled = true;
            if ( chkbox.checked == true )
            {
                isDisabled = false;
            }
            else
            {
                isDisabled = true;
            }
            for ( slot=0; slot < parseInt (noOfSlots,10); slot++ )
            {
                var qtyCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].qty']
                var priceCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].price']
                var confidenceLevelCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].confidenceLevel']
                var userList1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userList1']
                var userDate1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userDate1']
                var userTxt1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userTxt1']
                var userTxt2Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userTxt2']

                if ( qtyCtrl != null )
                {
                    qtyCtrl.disabled = isDisabled;
                }
                if ( priceCtrl != null )
                {
                    priceCtrl.disabled = isDisabled;
                }
               /* if ( confidenceLevelCtrl != null )
                {
                    confidenceLevelCtrl.disabled = isDisabled;
                }*/
                if ( userList1Ctrl != null )
                {
                    userList1Ctrl.disabled = isDisabled;
                }
                if ( userDate1Ctrl != null )
                {
                    userDate1Ctrl.disabled = isDisabled;
                }
                if ( userTxt1Ctrl != null )
                {
                    userTxt1Ctrl.disabled = isDisabled;
                }
                if ( userTxt2Ctrl != null )
                {
                    userTxt2Ctrl.disabled = isDisabled;
                }

				//SETTING THE DEFAULT VALUES
				if ( isDisabled == true )
				{
					var qtyDefaultCtrl 				= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].qty']
					var priceDefaultCtrl 			= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].price']
					var confidenceLevelDefaultCtrl 	= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].confidenceLevel']
					var userList1DefaultCtrl 		= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].userList1']
					var userDate1DefaultCtrl 		= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].userDate1']
					var userTxt1DefaultCtrl 		= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].userTxt1']
					var userTxt2DefaultCtrl 		= form['tableDataListDefaultValues[' + lineNo + '].slotDataList[' + slot + '].userTxt2']
					if ( qtyCtrl != null )
					{
						qtyCtrl.value = qtyDefaultCtrl.value;
					}
					if ( priceCtrl != null )
					{
						priceCtrl.value = priceDefaultCtrl.value;
					}
					if ( userList1Ctrl != null )
					{
						var ops = userList1Ctrl.options;
						for( var i=0;i < ops.length; i++ )
						{
							if( ops[i].value == userList1DefaultCtrl.value )
							{
								userList1Ctrl.selectedIndex = i;
								break;
							}
						}
					}
					if ( userDate1Ctrl != null )
					{
						userDate1Ctrl.value = userDate1DefaultCtrl.value;
					}
					if ( userTxt1Ctrl != null )
					{
						userTxt1Ctrl.value = userTxt1DefaultCtrl.value;
					}
					if ( userTxt2Ctrl != null )
					{
						userTxt2Ctrl.value = userTxt2DefaultCtrl.value;
					}
				} //END OF SETTING DEFAULT VALUES
            }

       }
       function showSumAvg()
       {
            if ( showSum() )
                showAvg();
       }
       function showSum ( )
       {
            var form = document.forecastEntryBuildForm;
            sum = 0;
            pa = document.getElementById ( 'errorsId' );
            pa.innerHTML = "";
            for ( slot = 0; slot < noOfSlots; slot++ )
            {
                var resultCtrl = form['buildRowData.slotDataList['+ slot +'].qty'];
                sum = 0;
                for ( row = 0; row < noOfRows; row++ )
                {
                    if ( form['tableDataList['+ row +'].selected'] != null )
                    {
                        if ( form['tableDataList['+ row +'].selected'].checked )
                        {
                            if ( isQtyValid ( form['tableDataList[' + row + '].slotDataList[' + slot + '].qty'], true ) )
                            {
                                sum = sum + parseInt ( form['tableDataList[' + row + '].slotDataList[' + slot + '].qty'].value, 10 )
                            }
                            else
                            {
                                pa.innerHTML = "<li>Please enter valid Quantity</li>"
                                form['tableDataList[' + row + '].slotDataList[' + slot + '].qty'].focus();
                                form['tableDataList[' + row + '].slotDataList[' + slot + '].qty'].select();
                                return false;
                            }
                        }
                    }
                }
                resultCtrl.value = sum;
            }
            return true;
       }
       function showAvg ( )
       {
           var form = document.forecastEntryBuildForm;
           pa = document.getElementById ( 'errorsId' );
            pa.innerHTML = "";
            sum = 0;
            count=0;
            for ( slot = 0; slot < noOfSlots; slot++ )
            {
                var resultCtrl = form['buildRowData.slotDataList['+ slot +'].price'];;
                if ( resultCtrl != null )
                {
                    sum = 0;
                    count = 0;
                    for ( row = 0; row < noOfRows; row++ )
                    {
                        if ( form['tableDataList['+ row +'].selected'] != null )
                        {
                            if ( form['tableDataList[' + row + '].slotDataList[' + slot + '].price'] != null )
                            {
                                if ( ( form['tableDataList['+ row +'].selected'].type == "hidden" && form['tableDataList['+ row +'].selected'].value == "true" ) || form['tableDataList['+ row +'].selected'].checked )
                                {
                                    if ( isPriceValid ( form['tableDataList[' + row + '].slotDataList[' + slot + '].price'] , true) )
                                    {
                                        if ( parseFloat ( form['tableDataList[' + row + '].slotDataList[' + slot + '].price'].value ) > 0 )
                                        {
                                            sum = sum + parseFloat ( form['tableDataList[' + row + '].slotDataList[' + slot + '].price'].value )
                                            count++;
                                        }
                                    }
                                    else
                                    {
                                        pa.innerHTML = "<li>Please enter valid Price</li>"
                                        form['tableDataList[' + row + '].slotDataList[' + slot + '].price'].focus();
                                        form['tableDataList[' + row + '].slotDataList[' + slot + '].price'].select();
                                        return false;
                                    }
                                }
                            }
                        }
                    }
                    if ( count == 0 ) count = 1;
                    var result = Math.round((sum/count)*100)/100; //cutting down to upto 2 decimal places.
                    result = result + "";
                    var arr = result.split( '.' );
                    if ( arr.length == 1 )
                    {
                        result = result + ".00";
                    }
                    else if ( arr[1].length == 0 )
                    {
                        result = result + "00";
                    }
                    else if ( arr[1].length == 1 )
                    {
                        result = result + "0"
                    }
                    resultCtrl.value = result;
                }
            }
       }
       function openEditColumnWindow()
       {
            newWindow = window.open ('searchMetaData.do?action=edit&tableName=BUILDFORECAST','editColumnPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=auto,width=525 height=400,resizable=yes,left=300,top=130');
            newWindow.focus();
       }
       function openExportFileWindow()
       {
            newWindow = window.open ('export_to_file.html','exportToFilePopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=no,width=300 height=270,resizable=no,left=550,top=180');
            newWindow.focus();
       }
       function onSubmit ( actionName )
       {
            var form = document.forecastEntryBuildForm;
            if ( <%--isCheckboxSelected() &&--%> isValidEntry( ) )
            {
                form.action.value = actionName;
                form.submit();
            }
       }
       function onCancel()
       {
            var form = document.forecastEntryBuildForm;
            form.action.value = 'search';
            form.submit();
       }
       function search()
       {
            document.forecastEntryBuildForm.action.value = "reloadTableColumns";
			enableFields();
            document.forecastEntryBuildForm.submit();
        }
        function onReset ( )
        {
            var form = document.forecastEntryBuildForm;
            form.reset();
            for ( row=0; row < noOfRows; row++ )
            {
               if ( form['tableDataList['+ row +'].selected'] != null )
               {
                    toggleEnableDisable( form['tableDataList['+ row +'].selected'], row );
               }
            }
        }
        var dateElement = "";
        function openCalendar(dateValue, row)
        {
            var form = document.forecastEntryBuildForm;
            pa = document.getElementById ( 'errorsId' );
            pa.innerHTML = "";
            if ( form['tableDataList['+ row +'].selected'] != null )
            {
                if ( !form['tableDataList['+ row +'].selected'].checked )
                {
                    pa.innerHTML = "<li>Please Select Checkbox</li>"
                    return;
                }
            }
            dateElement = dateValue;
            newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
            newWindow.moveTo(550,180);
            newWindow.focus();
        }

        function assignDate(passedValue)
        {
            dateElement.value=passedValue;
            window.focus();
        }
        function isValidDate( dateCtrl ) //allows empty
        {
            if( chkDate(dateCtrl.value,"","N") == false)
            {
                return false;
            }
            return true;
        }
        function isPriceValid( priceCtrl, isZeroAllowed ) //replaces 0.0 if price is empty
        {
            if( priceCtrl.value != '')
            {
                var j = 0;
                for(var k = 0; k < (priceCtrl.value).length;k++)
                {
                    var c = (priceCtrl.value).charAt(k);
                    if( c == '.' )
                    {
                        j++;
                        if(j > 1 )
                        {
                            return false;
                        }
                    }
                }
                if(check_char_position4(priceCtrl.value) || (is_Sp_Characters_frieght(priceCtrl.value) == false) )
                {
                     return false;
                }
                if ( !isZeroAllowed )
                {
                    if ( parseFloat ( priceCtrl.value ) <= 0 )
                    {
                        return false;
                    }
                }
            }
            else
            {
                priceCtrl.value = "0.0"
                if ( !isZeroAllowed )
                {
                    return false;
                }
            }
            return true;
        }
        function isQtyValid ( qtyCtrl, isZeroAllowed )
        {
            if( qtyCtrl.value != '')
            {
                if( !isInteger(qtyCtrl.value) )
                {
                     return false;
                }
                if ( !isZeroAllowed )
                {
                    if ( parseInt ( qtyCtrl.value, 10 ) <= 0 )
                    {
                        return false;
                    }
                }
            }
            else
            {
                qtyCtrl.value = "0"
                if ( !isZeroAllowed )
                {
                    return false;
                }
            }
            return true;
        }
        function isValidConfidenceLevel( clCtrl )
        {
            if( clCtrl.value != '')
            {
                var j = 0;
                for(var k = 0; k < (clCtrl.value).length; k++)
                {
                    var c = (clCtrl.value).charAt(k);
                    if( c == '.' )
                    {
                        j++;
                        if(j > 1 )
                        {
                            return false;
                        }
                    }
                }
                if(check_char_position4(clCtrl.value) || (is_Sp_Characters_frieght(clCtrl.value) == false)  )
                {
                    return false;
                }
                if( clCtrl.value > 100 )
                {
                    return false;
                }
            }
            else
            {
                clCtrl.value = "0.0"
            }
            return true;
        }
        function isValidEntry()
        {
            var form = document.forecastEntryBuildForm;
            pa = document.getElementById ( 'errorsId' );
            pa.innerHTML = "";
			var isQtyEntered = false;
            for ( slot = 0; slot < noOfSlots; slot++ )
            {
				var isSlotQtyEntered = false;
                var buildQtyCtrl = form['buildRowData.slotDataList[' + slot + '].qty']
                var buildPriceCtrl = form['buildRowData.slotDataList[' + slot + '].price']
                if ( buildQtyCtrl != null )
                {
                    if ( !isQtyValid( buildQtyCtrl, true ) )
                    {
                         pa.innerHTML = "<li>Please enter valid Quantity for Default Build</li>"
                        buildQtyCtrl.select();
                        buildQtyCtrl.focus();
                        return false;
                    }
					if ( parseInt ( buildQtyCtrl.value, 10 ) > 0 )
					{
						isQtyEntered = true;
						isSlotQtyEntered = true;
					}
                }
                if ( buildPriceCtrl != null )
                {
                    if ( !isPriceValid( buildPriceCtrl, true ) )
                    {
                        pa.innerHTML = "<li>Please enter valid Price for Default Build</li>"
                        buildPriceCtrl.select();
                        buildPriceCtrl.focus();
                        return false;
                    }
					if ( parseFloat ( buildPriceCtrl.value ) > 0 && !isSlotQtyEntered )
					{
						pa.innerHTML = "<li>Please enter valid Quantity for Default Build</li>"
                        buildQtyCtrl.select();
                        buildQtyCtrl.focus();
                        return false;
					}
                }
            }
			if ( !isQtyEntered )
			{
				pa.innerHTML = "<li>Please enter Quantity for Default Build</li>"
				return false;
			}

            for ( row = 0; row < noOfRows; row++ )
            {
                if ( form['tableDataList['+ row +'].selected'] != null )
                {
                    if ( form['tableDataList['+ row +'].selected'].checked )
                    {
						isQtyEntered = false;
                        for ( slot = 0; slot < noOfSlots; slot++ )
                        {
							var isSlotQtyEntered = false;
                            var qtyCtrl = form['tableDataList[' + row + '].slotDataList[' + slot + '].qty']
                            var priceCtrl = form['tableDataList[' + row + '].slotDataList[' + slot + '].price']
                            var confidenceLevelCtrl = form['tableDataList[' + row + '].slotDataList[' + slot + '].confidenceLevel']
                            var userDate1Ctrl = form['tableDataList[' + row + '].slotDataList[' + slot + '].userDate1']
                            var salesPersonName = form['tableDataList[' + row + '].salesPersonName'].value;

                            if ( qtyCtrl != null )
                            {
                                if ( !isQtyValid( qtyCtrl, true ) )
                                {
                                    if ( noOfRows > 1 )
                                        pa.innerHTML = "<li>Please enter valid Quantity for Sales Person '" +  salesPersonName +"'</li>"
                                    else
                                        pa.innerHTML = "<li>Please enter valid Quantity</li>"
                                    qtyCtrl.select();
                                    qtyCtrl.focus();
                                    return false;
                                }
								if ( parseInt ( qtyCtrl.value, 10 ) > 0 )
								{
									isQtyEntered = true;
									isSlotQtyEntered = true;
								}
                            }
                            if ( priceCtrl != null )
                            {
                                if ( !isPriceValid( priceCtrl, true ) )
                                {
                                    if ( noOfRows > 1 )
                                        pa.innerHTML = "<li>Please enter valid Price for Sales Person '" +  salesPersonName +"'</li>"
                                    else
                                        pa.innerHTML = "<li>Please enter valid Price</li>"
                                    priceCtrl.select();
                                    priceCtrl.focus();
                                    return false;
                                }
								if ( parseFloat ( priceCtrl.value ) > 0 && !isSlotQtyEntered )
								{
									pa.innerHTML = "<li>Please enter valid Quantity for Sales Person '" +  salesPersonName +"'</li>"
									qtyCtrl.select();
									qtyCtrl.focus();
									return false;
								}
                            }
                            if ( confidenceLevelCtrl != null )
                            {
                                if ( !isValidConfidenceLevel( confidenceLevelCtrl ) )
                                {
                                    if ( noOfRows > 1 )
                                        pa.innerHTML = "<li>Please enter valid Confidence Level ( should be 0 to 100 ) for Sales Person '" +  salesPersonName +"'</li>"
                                    else
                                        pa.innerHTML = "<li>Please enter valid Confidence Level ( should be 0 to 100 )</li>"
                                    confidenceLevelCtrl.select();
                                    confidenceLevelCtrl.focus();
                                    return false;
                                }
                            }
                            if ( userDate1Ctrl != null )
                            {
                                if ( !isValidDate( userDate1Ctrl ) )
                                {
                                    if ( noOfRows > 1 )
                                        pa.innerHTML = "<li>Please enter valid Date for Sales Person '" +  salesPersonName +"'</li>"
                                    else
                                        pa.innerHTML = "<li>Please enter valid Date</li>"
                                    userDate1Ctrl.select();
                                    userDate1Ctrl.focus();
                                    return false;
                                }
                            }
                        }
						if ( !isQtyEntered )
						{
							pa.innerHTML = "<li>Please enter Quantity for Sales Person '" +  salesPersonName + "'</li>"
							return false;
						}
                    }
                }
            }
           return true;
        }
        function isCheckboxSelected()
        {
            var form = document.forecastEntryBuildForm;
            pa = document.getElementById ( 'errorsId' );
            pa.innerHTML = "";
            var selectedCnt = 0;
            for ( row = 0; row < noOfRows; row++ )
            {
                if ( form['tableDataList['+ row +'].selected'] != null )
                {
                    if ( ( form['tableDataList['+ row +'].selected'].type == "hidden" && form['tableDataList['+ row +'].selected'].value == "true" ) || form['tableDataList['+ row +'].selected'].checked )
                    {
                        selectedCnt = selectedCnt + 1;
                    }
                }
                if ( selectedCnt > 0 )
                {
                    break;
                }
            }
            if ( selectedCnt > 0 )
            {
                return true;
            }
            else
            {
                pa.innerHTML = "<li>Please select atleast one checkbox</li>"
                return false;
            }
        }
        function storePrevValue( ctrl )
        {
            prevPrice = ctrl.value;
        }

		function enableFields ( )
		{
			var form = document.forecastEntryBuildForm;
            for ( row=0; row < noOfRows; row++ )
            {
               if ( form['tableDataList['+ row +'].selected'] != null && form['tableDataList['+ row +'].selected'].type == "checkbox")
               {
                    enableRow( row );
               }
            }
		}
		function enableRow( lineNo ) //lineNo --> starts from zero
       	{
            var form = document.forecastEntryBuildForm;
            var isDisabled = false;
            for ( slot=0; slot < parseInt (noOfSlots, 10); slot++ )
            {
                var qtyCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].qty']
                var priceCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].price']
                var confidenceLevelCtrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].confidenceLevel']
                var userList1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userList1']
                var userDate1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userDate1']
                var userTxt1Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userTxt1']
                var userTxt2Ctrl = form['tableDataList[' + lineNo + '].slotDataList[' + slot + '].userTxt2']

                if ( qtyCtrl != null )
                {
                    qtyCtrl.disabled = isDisabled;
                }
                if ( priceCtrl != null )
                {
                    priceCtrl.disabled = isDisabled;
                }
               /* if ( confidenceLevelCtrl != null )
                {
                    confidenceLevelCtrl.disabled = isDisabled;
                }*/
                if ( userList1Ctrl != null )
                {
                    userList1Ctrl.disabled = isDisabled;
                }
                if ( userDate1Ctrl != null )
                {
                    userDate1Ctrl.disabled = isDisabled;
                }
                if ( userTxt1Ctrl != null )
                {
                    userTxt1Ctrl.disabled = isDisabled;
                }
                if ( userTxt2Ctrl != null )
                {
                    userTxt2Ctrl.disabled = isDisabled;
                }
            }
       	}
       </SCRIPT>

<META content="MSHTML 6.00.2800.1458" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginwidth="0" marginheight="0" <%--onLoad="showSum();showAvg();"--%> >
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><!--TBODY-->
 <TBODY>
 <TR>


   <TD vAlign=top width=180
   background="<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif">
 <!-- Side Navigation start -->
    <%@ include file="/jsp/marketing/marketing_menu.jsp" %>
 <!-- end of the side navigations -->
   </TD>
   <TD bgColor=#ffffff><IMG height=9
     src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
   <TD bgColor=#ffffff><IMG height=480
     src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=10></TD>
   <TD vAlign=top width="100%"><IMG height=1
     src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0> <BR>
<!-- from here your body starts -->

<html:form  action="/forecastEntryBuildAction" name="forecastEntryBuildForm" type="com.scalar.forecast.forecastEntry.forms.ForecastEntryForm" >
<html:hidden property="build"/>
<input type="hidden" name="action" value="">
        <script>
               noOfSlots=<nested:write property="showNext" />;
        </script>
     <TABLE width="100%" align=center border=0>
       <TBODY>
       <TR>

         <TD class=NArialW align=middle colSpan=5>Build Forecast</TD></TR>
       <TR>
            <TD colSpan=5>&nbsp;</TD></TR>
        <TR><TD colspan='5' id='errorMessagesId'><chiptrack:errors styleClass='NArialL' /></TD></TR>
        <TR><TD colspan='5' id='infoMessagesId'><chiptrack:info styleClass='NArialL' /></TD></TR>
        <TR><TD colspan='5' class="NArialL"><FONT id="errorsId"  color='FF0000'></FONT></TD></TR>
        <% if ( !user1.isActionAllowed ( Functionality.BUILD_FORECAST,User.USER_ACTION_MODIFY ) )
            {
        %>
               <TR><TD colspan=5 align='left'><font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></TD></TR>
        <%  } %>
        <TR><TD colSpan=5>&nbsp;</TD></TR>
       <TR>
         <TD>
           <TABLE width="100%" border=0>
             <TBODY>
             <% int tdIdxCnt = 0; %>
              <nested:iterate property="searchFieldList" indexId="idx" id="searchField">
                <nested:equal property="display" value="true">
                   <% Integer tdidx = new Integer ( (++tdIdxCnt)%2 );
                      pageContext.setAttribute( "tdidx",tdidx );%>
                   <logic:equal name="tdidx" value="1" scope="page">
                      <TR>
                        <TD width="20%"><FONT class=NArialL><nested:write property="displayName"/>:</FONT></TD>
                        <TD class=NArialL width="25%"><nested:write property="propertyValue"/>
                            <nested:equal property="displayName" value="Show Next">
                                &nbsp;<bean:write name="showNext" scope="request"/>
                            </nested:equal>
                        </TD>
                   </logic:equal>
                   <logic:equal name="tdidx" value="0" scope="page">
                        <TD width="5%">&nbsp;</TD>
                        <TD class=NArialL width="20%"><nested:write property="displayName"/>:</TD>
                        <TD class=NArialL width="30%"><nested:write property="propertyValue"/>
                            <nested:equal property="displayName" value="Show Next">
                                &nbsp;<bean:write name="showNext" scope="request"/>
                            </nested:equal>
                       </TD>
                     </TR>
                   </logic:equal>
                </nested:equal>
              </nested:iterate>
             <TR>
               <TD bgColor=#ffffff><IMG height=9
                 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD></TR>
             <TR>
               <TD width="100%" colSpan=5><!-- sales forecast entry table starts here -->
                 <TABLE width="100%" border=0>
                   <TBODY>
                <TR align=middle>
                    <TD colspan=10 class=NArialL><chiptrack:restrictedLink functionality='<%=Functionality.BUILD_FORECAST%>' action='<%=User.USER_ACTION_VIEW%>' href="javascript:openEditColumnWindow()" onmouseover="window.status='Click to Open Edit Column Dispalay Window';return true" onmouseout="window.status='';return true">[ Edit Column Display ]</chiptrack:restrictedLink>&nbsp;&nbsp;&nbsp;&nbsp;<%--<A href="javascript:openExportFileWindow()">[ Export to File ]</A>--%></TD>
                </TR>

                <TR>
                    <TD height=5><IMG
                             src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"
                             width=10 height=5></TD>
                </TR>

                   <TR align=middle bgColor=#993333>

                        <TD align=middle><FONT class=NArialL style="color:#ffffff;">Sales Person</FONT></TD>


             <nested:nest property="tableMetaData">
                <nested:iterate property="slotNames">

                     <TD align=middle colSpan='<nested:write property="tableMetaData/noOfTableColumns" />' ><FONT class=NArialL
                       style="color:#ffffff;"><nested:write property="label"/></FONT></TD>
                </nested:iterate>
                   </TR>
                   <TR align=middle bgColor=#f2dbdb>
                            <TD></TD>
                 <nested:iterate property="slotNames">
                    <nested:nest property="/tableMetaData">
                    <nested:iterate property="tableColumnList">
                        <nested:equal property="display" value="true">
                            <TD class=NArialL noWrap <%--width=55--%> align="center"><nested:write property="displayName"/><%--Qty--%></TD>
                        </nested:equal>
                    </nested:iterate>
                    </nested:nest>
                 </nested:iterate>
             </nested:nest>
                   </TR>

                   <jsp:include page="/jsp/forecast/forecast_entry_build_table_data.jsp" flush="true"/>

                <%-- BACKLOG DISPLAY STARTS HERE--%>
                 <logic:iterate name="backlogInfoList" indexId="backlogInfoListIdx" id="rowData" scope="request">
                    <logic:equal name="backlogInfoListIdx" value="0" scope="page">
                        <TR bgcolor="#AAAAFF">
                            <%
                                ForecastEntryForm forecastEntryBuildForm = ( ForecastEntryForm ) session.getAttribute ( "forecastEntryBuildForm");
                                int totalNoOfColumns = 0;
                                if ( forecastEntryBuildForm != null )
                                {
                                    int showNext = forecastEntryBuildForm.getShowNext();
                                    int columnsInEachSlot = forecastEntryBuildForm.getTableMetaData().getNoOfTableColumns();
                                    totalNoOfColumns = ( showNext * columnsInEachSlot ) + 1;
                                }
                            %>
                            <TD colspan=<%= totalNoOfColumns %> >&nbsp;</TD>
                        </TR>
                    </logic:equal>
                  <TR align="right" bgcolor='<%=backlogInfoListIdx.intValue()%2 == 0 ? "#DEE1E2" : "#FFF1FF"%>'  >
                    <TD class="NARIAlL">
                       <bean:write name="rowData" property="salesPersonName" filter="false"/>
                    </TD>

                           <logic:iterate name="rowData" property="slotDataList" indexId="slotDataListIdx" id="slotData">
                                <nested:nest property="/tableMetaData">
                                    <nested:iterate property="tableColumnList">
                                     <nested:equal property="display" value="true">
                                        <nested:equal property="name" value="Qty">
                                            <TD class=NArialL valign="top" nowrap>
                                                <bean:write name="slotData" property="qty"/>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="Price">
                                            <TD class=NArialL valign="top" nowrap>
                                                <bean:write name="slotData" property="priceAsString"/>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="Confidence Level">
                                            <TD class=NArialL valign="top" nowrap>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="<%=Constants.COLUMN_USERLIST1%>">
                                            <TD class=NArialL valign="top" nowrap>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="<%=Constants.COLUMN_USERDATE1%>">
                                            <TD class=NArialL valign="top" nowrap>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="<%=Constants.COLUMN_USERTXT1%>">
                                            <TD class=NArialL valign="top" nowrap>
                                            </TD>
                                        </nested:equal>
                                        <nested:equal property="name" value="<%=Constants.COLUMN_USERTXT2%>">
                                            <TD class=NArialL valign="top" nowrap>
                                            </TD>
                                        </nested:equal>
                                     </nested:equal>
                                    </nested:iterate>
                                </nested:nest>
                           </logic:iterate>
                 </TR>
                 </logic:iterate>
                 <%-- BACKLOG DISPLAY ENDS HERE --%>


                 </TBODY></TABLE><!-- sales forecast entry table ends here -->
                 <%--<input type="hidden" name="action" value="" >--%>

        </TD></TR></TBODY></TABLE></TD></TR>
       <TR>
         <TD><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"
width=10></TD></TR>
       <TR>


         <TD align=middle colSpan=5>
                <chiptrack:restrictedLink functionality='<%=Functionality.BUILD_FORECAST%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:onSubmit('save');" onmouseover="window.status='Click to Save Forecast';return true" onmouseout="window.status='';return true">
                <img src="<%=chipTracContext%>/jsp/includes/images/save.gif" border='0' title="Click to Save Forecast"></chiptrack:restrictedLink>
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A
           href="javascript:onReset();"><IMG
           onmouseover="window.status='Click to Reset';return true"
           title="Click here to Reset"
           onmouseout="window.status='';return true" height=17
           src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width=53 border=0></A>
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A
           href="javascript:onCancel();"><IMG
           onmouseover="window.status='Click to Cancel';return true"
           title="Click here to Cancel"
           onmouseout="window.status='';return true" height=17
           src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width=53
         border=0></A></TD></TR></TBODY></TABLE>
<!-- Body Ends Here -->
        </TD>
    </TR>
</html:form>
    </TBODY>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>